package dispatcher.person.gui;

import java.util.ArrayList;

import state.person.PersonType;
import system.Constant;
import dispatcher.gui.state.GroupDispatcherStateHandler;

/**
 * This method is used as a helper class for creating the different combo box choices
 * @author Caleb
 *
 */
public class PersonDispatcherViewComboBoxHelper {
	
	/**
	 * This method will create the different number of floors in string array format
	 * @return Returns the number of floors from 1 - max floor (inclusively) in a string array
	 */
	public static String[] getFloorSelection(){
		String floors[] = new String[0];
		
		int maxFloors = GroupDispatcherStateHandler.getInstance().getMaxFloors();
		
		if (maxFloors > 0){
			floors = new String[maxFloors];
			// Loops through all the floors and creates a string from them
			floors[0] = "Lobby";
			for(int i = 1; i < maxFloors; i++){
				floors[i] = "" + (i + 1 - Constant.DEFAULT_FLOOR_START);
			}
		}
		
		return floors;
	}
	
	/**
	 * This method will create the different number of people types in string array format
	 * @return Returns the number people types in string array
	 */
	public static String[] getPersonTypeSelection(){
		
		ArrayList<String> personType = new ArrayList<String>();
		
		int index = 1;
		// This will loop from person id 0x01 to n until a null is return as an invalid id
		while(true){
			PersonType type = PersonType.getPersonTypeForId((byte)index);
			if (type == null){
				break;
			}
			personType.add("" + type);
			index++;
		}
		if (personType.size() == 0){
			return new String[0];
		}
		
		if (Constant.USING_DEBUG_TESTING_MODE){
			personType.add("" + PersonType.Dummy);
		}
		
		return (String[])personType.toArray(new String[personType.size()]);
	}
}
